<!--  -->
<template>
  <div>
    <div class="tools">
      <div>
        <el-radio @change="getList()" v-model="radio" label="0">待审核</el-radio>
        <el-radio @change="getList()" v-model="radio" label="1">审核驳回</el-radio>
        <el-radio @change="getList()" v-model="radio" label="2">审核通过</el-radio>

        <!-- <el-input
          prefix-icon="el-icon-search"
          style="width: 200px;margin-right: 10px;"
          size="small"
          v-model="userName"
          placeholder="请输入内容"
        ></el-input>
        <el-button icon="el-icon-search" type="primary" size="small">搜索</el-button>-->
      </div>
    </div>
    <el-table :data="tableData" style="width: 100%">
      <el-table-column label="编号" style="width:100%">
        <template slot-scope="scope">
          <i class="el-icon-time"></i>
          <span style="margin-left: 10px">{{ scope.$index + 1 }}</span>
        </template>
      </el-table-column>
      <el-table-column label="文章名" style="width:100%">
        <template slot-scope="scope">
          <el-tag @click="goInfo(scope.row.id)" size="medium">{{ scope.row.articlename }}</el-tag>
        </template>
      </el-table-column>
      <el-table-column label="发布人" style="width:100%">
        <template slot-scope="scope">
          <el-tag size="medium">{{ scope.row.userName }}</el-tag>
        </template>
      </el-table-column>
      <el-table-column label="状态" style="width:100%">
        <template slot-scope="scope">
          <el-tag v-if="scope.row.auditstatus == 0" size="medium" type="warning">待审核</el-tag>
          <el-tag v-if="scope.row.auditstatus == 1" size="medium" type="danger">审核不通过</el-tag>
          <el-tag v-if="scope.row.auditstatus == 2" size="medium" type="success">审核通过</el-tag>
        </template>
      </el-table-column>
      <el-table-column prop="createtime" sortable label="创建日期"></el-table-column>
      <el-table-column label="操作" style="width:100%">
        <template slot-scope="scope">
          <el-button
            v-if="scope.row.auditstatus == 0 || scope.row.auditstatus == 1"
            size="mini"
            type="danger"
            @click="check(scope.row,2)"
          >审核</el-button>
          <el-button v-else size="mini" type="danger" @click="check(scope.row,1)">驳回</el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import ArticleInfo from "@/view/life/modules/ArticleInfo";
export default {
  name: "",
  props: [""],
  data() {
    return {
      tableData: [],
      userName: "",
      dialogVisible: false,
      radio: "1"
    };
  },
  components: {
    ArticleInfo
  },
  computed: {},
  beforeMount() {},
  mounted() {
    this.getArticleList();
  },
  methods: {
    //获取文章列表
    getArticleList() {
      this.getRequest("/life/articles-base/getArticleList", {
        pageNo: 1,
        pageSize: 10
      }).then(res => {
        console.log(res);
        this.tableData = res.data.records;
      });
    },
    goInfo(e) {
      this.$router.push({
        path: "/articleInfo",
        query: { id: e }
      });
    },
    check(e, state) {
      let id = e.id;
      this.$confirm("确定操作?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      }).then(() => {
        this.getRequest("/life/articles-base/changeState", {
          id,
          state
        });
        this.getArticleList();
      });
    },
    getList() {
      this.getRequest("/life/articles-base/getArticleList", {
        pageNo: 1,
        pageSize: 10,
        state:this.radio
      }).then(res => {
        console.log(res);
        this.tableData = res.data.records;
      });
    }
  },
  watch: {}
};
</script>

<style lang='css' scoped>
.tools {
  display: flex;
  justify-content: space-between;
}
</style>